package cn.edu.nwafu.core.service.impl;

import cn.edu.nwafu.core.config.LocalDateTimeConverter;
import cn.edu.nwafu.core.listener.ExcelAircraftInfoListener;
import cn.edu.nwafu.core.mapper.AircraftInfoMapper;
import cn.edu.nwafu.core.pojo.entity.AircraftInfo;
import cn.edu.nwafu.core.service.AircraftInfoService;
import com.alibaba.excel.EasyExcel;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.io.InputStream;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author zhanghao
 * @since 2021-10-30
 */
@Service
public class AircraftInfoServiceImpl extends ServiceImpl<AircraftInfoMapper, AircraftInfo> implements AircraftInfoService {

    @Transactional(rollbackFor = Exception.class)
    @Override
    public void importData(InputStream inputStream) {
        EasyExcel.read(inputStream, AircraftInfo.class, new ExcelAircraftInfoListener(baseMapper))
                .registerConverter(new LocalDateTimeConverter()).sheet().doRead();
    }
}
